<template>
  <div>
    <div class="his-hot" v-show="isShow">
      <div class="hd">
        <h4>历史记录</h4>
        <van-icon name="delete-o" @click="clear" />
      </div>
      <div class="bd">
        <van-tag
          @click="tagClick(item)"
          plain
          type="primary"
          v-for="(item, index) in hoistoryListData"
          :key="index"
          >{{ item }}</van-tag
        >
      </div>
    </div>
    <div class="his-hot">
      <div class="hd">
        <h4>热门搜索</h4>
      </div>
      <div class="bd">
        <van-tag
          @click="tagClick(item.keyword)"
          plain
          :type="item.is_hot ? 'danger ' : 'primary '"
          v-for="(item, index) in hotListData"
          :key="index"
          >{{ item.keyword }}</van-tag
        >
      </div>
    </div>
  </div>
</template>

<script>
import { clearHistorySearch } from "@/request/api";
export default {
  data() {
    return {
      isShow: true,
    };
  },
  props: ["hotListData", "hoistoryListData"],
  methods: {
    tagClick(val) {
      this.$emit("onSearch", val);
    },
    clear() {
      clearHistorySearch().then((res) => {
        // console.log(res);
        this.$toast.success("删除成功");
        setTimeout(() => {
          this.isShow = false;
        }, 1000);
      });
    },
  },
};
</script>
 
<style lang = "less" scoped>
.red {
  color: red;
}
.his-hot {
  padding: 0.1rem 0.1rem 0;
  background-color: rgb(198, 227, 238);
  margin-bottom: 0.2rem;
  .hd {
    display: flex;
    justify-content: space-between;
    font-size: 0.2rem;
    margin-bottom: 0.1rem;
    .van-icon {
      font-size: 0.24rem;
    }
  }
  .bd {
    .van-tag {
      margin-right: 0.1rem;
      padding: 0.03rem;
      margin-bottom: 0.1rem;
    }
  }
}
</style>